package com.atguigu1.core.operator

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
 *
 * @description: 分区内取最大值,分区间取最大值求和
 * @time: 2021-03-12 11:45
 * @author: baojinlong
 **/
object Spark12Filter {
  def main(args: Array[String]): Unit = {
    val conf: SparkConf = new SparkConf().setMaster("local[*]").setAppName("rdd")
    // 设置rdd分区数字
    val sparkContext = new SparkContext(conf)
    val rddValue: RDD[Int] = sparkContext.makeRDD(List(1, 2, 3, 4), 2)

    /**
     * filter有可能产生数据倾斜
     */
    rddValue.filter(_ % 2 == 1).collect().foreach(println)
    sparkContext.stop()
  }
}
